<script setup lang="ts">
import APILayout from '@/api/layout/index'
import type { Config } from '@/api/layout/types'
import { usePidMenu } from '@/stores'

const config = ref<Config>()

const { getAllBasic } = usePidMenu()

const { allBasic } = storeToRefs(usePidMenu())

getAllBasic()

watch(() => allBasic.value.getConfig, (data) => {
    config.value = data
}, { immediate: true })

const $router = useRouter()

function handleJumpView(name: string) {
    window.open(`${import.meta.env.VITE_APP_WEB_URL}/${name}`)
}

</script>

<template>
    <div class="footer">
        <div class="top">
            <div class="top-left">
                <div class="logo">
                    <img src="./images/logo.svg" alt="心安元素">
                </div>
                <p>{{ config?.site_brief }}</p>
            </div>
            <div class="top-right">
                <ul class="list">
                    <li class="item">
                        <h1 class="title">主要产品</h1>
                        <ul>
                            <li @click="handleJumpView('')">视频</li>
                            <li @click="handleJumpView('picture')">图片</li>
                            <li @click="handleJumpView('music')">音乐</li>
                            <li @click="handleJumpView('font')">字体</li>
                        </ul>
                    </li>
                    <li class="item">
                        <h1 class="title">商务服务</h1>
                        <ul>
                            <li @click="handleJumpView('entry')">入职心安元素</li>
                            <li @click="handleJumpView('cooperation')">合作客户</li>
                            <li @click="handleJumpView('service')">在线客服</li>
                            <li @click="handleJumpView('help')">帮助中心</li>
                            <li @click="handleJumpView('feedback')">意见反馈</li>
                        </ul>
                    </li>
                    <li class="item">
                        <h1 class="title">心安元素</h1>
                        <ul>
                            <li @click="handleJumpView('about')">关于心安元素</li>
                            <li @click="handleJumpView('activity-all')">心安元素活动</li>
                            <li @click="handleJumpView('notice')">通知及公告</li>
                            <li @click="handleJumpView('agreement')">隐私政策及协议</li>
                        </ul>
                    </li>
                    <li class="item">
                        <h1 class="title">关注&联系</h1>
                        <div>
                            <img v-if="config?.square_code" :src="config.square_code" alt="img-1">
                            <img v-if="config?.round_code" :src="config.round_code" alt="img-2">
                        </div>
                        <p>客服热线：{{ config?.customer_hotline }}（周一至周五9:00--18:00）</p>
                        <p>商务合作：{{ config?.customer_cooperation }}</p>
                    </li>
                </ul>
            </div>
        </div>
        <div class="bottom">
            <div>{{ config?.site_copyright }}</div>
            <div><a href="https://beian.miit.gov.cn/" target="_blank">{{ config?.site_beian_web }}</a></div>
            <div>{{ config?.site_icp }}</div>
            <div><img src="./images/public-security.png" alt="public-security">{{ config?.site_beian }}</div>
            <div>
                <a :href="config?.business" target="_blank">营业执照</a>
            </div>
        </div>
    </div>
</template>

<style lang="scss" scoped>
.footer {
    border-top: 1px solid #BBBBBB;
    min-width: 1340px;

    .bottom {
        height: 60px;
        line-height: 23px;
        background-color: rgba(219, 219, 219, 1);
        display: flex;
        align-items: center;
        justify-content: center;

        div {
            color: rgba(154, 154, 154, 1);
            font-size: 16px;
            line-height: 1em;
            padding: 0 20px;
            display: flex;
            align-items: center;
            font-family: 'SOURCEHANSANSCN-EXTRALIGHT';

            a {
                font-size: 16px;
                line-height: 1em;
                color: rgba(154, 154, 154, 1);
                text-decoration: none;
            }

            img {
                display: block;
                margin-right: 3px;
            }

            &:not(&:last-child) {
                border-right: 2px solid rgba(187, 187, 187, 1);
            }

        }
    }

    .top {
        display: flex;
        margin: 37px 0;

        .top-right {
            flex: 3;
            padding-bottom: 20px;

            .list {
                width: 80%;
                margin: 0 auto;
                display: grid;
                margin: 0 auto;
                grid-template-columns: repeat(3, 1fr) 2fr;
                list-style: none;
                margin-top: 5px;

                .item {
                    p {
                        color: rgba(154, 154, 154, 1);
                        font-size: 16px;
                        margin: 10px 0;
                        font-family: 'SOURCEHANSANSCN-EXTRALIGHT';
                    }

                    div {
                        margin-top: 15px;
                        display: flex;

                        img {
                            display: block;
                            width: 120px;
                            height: 120px;

                            &:last-child {
                                margin-left: 30px;
                            }
                        }
                    }

                    .title {
                        font-size: 20px;
                        color: #101010;
                        border-bottom: 3px solid var(--primary-color);
                        min-width: 100px;
                        display: inline;
                        font-weight: 400;
                        padding-bottom: 5px;
                    }

                    ul {
                        list-style: none;
                        margin-top: 20px;

                        li {
                            color: rgba(154, 154, 154, 1);
                            font-size: 16px;
                            margin: 8px 0;
                            cursor: pointer;
                            font-family: 'SOURCEHANSANSCN-EXTRALIGHT';
                        }
                    }
                }
            }
        }

        .top-left {
            flex: 2;
            margin: 0 auto;
            border-right: 1px solid #BBBBBB;
            padding-top: 25px;

            .logo {
                width: 380px;
                margin: 0 auto;

                img {
                    width: 172.48px;
                    height: 51.65px;
                }
            }

            p {
                width: 380px;
                color: rgba(154, 154, 154, 1);
                font-size: 16px;
                margin: 0 auto;
                margin-top: 33px;
                font-family: 'SOURCEHANSANSCN-EXTRALIGHT';
            }
        }
    }
}
</style>
